/*
 * TaskContract.java
 *
 * Copyright (C) 2012 Marten Gajda <marten@dmfs.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published
 * by the Free Software Foundation; either version 2 of the License,
 * or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 * USA
 */

package ms.jung.andorid.caldavtodo;

import android.net.Uri;

/**
 * Task contract. This class defines the interface to the task provider.
 * 
 * TODO: add mapping for categories/tasks
 * 
 * @author Marten Gajda <marten@dmfs.org>
 * 
 */
public final class TaskContract {

    private static final String TAG = "Tasks";

    /**
     * Task provider authority.
     */
    public static final String AUTHORITY = "ms.jung.android.caldavtodo.provider";

    /**
     * Base content URI.
     */
    public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY);

    /**
     * URI parameter to signal that the caller is a sync adapter.
     */
    public static final String CALLER_IS_SYNCADAPTER = "caller_is_syncadapter";

    /**
     * URI parameter to submit the account name of the account we operate on.
     */
    public static final String ACCOUNT_NAME = "account_name";

    /**
     * URI parameter to submit the account type of the account we operate on.
     */
    public static final String ACCOUNT_TYPE = "account_type";

    /**
     * URI parameter value to select a local, unsynced task list.
     */
    public static final String LOCAL_ACCOUNT = "LOCAL";

    /**
     * Private constructor to prevent instantiation.
     */
    private TaskContract() {
    }

    public interface CommonSyncColumns {

	public static final String ACCOUNT_NAME = "account_name";

	public static final String ACCOUNT_TYPE = "account_type";

	public static final String SYNC_SOURCE = "sync_source";

	public static final String SYNC_VERSION = "sync_version";

	public static final String _DIRTY = "_dirty";

	public static final String SYNC1 = "sync1";

	public static final String SYNC2 = "sync2";

	public static final String SYNC3 = "sync3";

	public static final String SYNC4 = "sync4";

	public static final String SYNC5 = "sync5";

	public static final String SYNC6 = "sync6";

	public static final String SYNC7 = "sync7";

	public static final String SYNC8 = "sync8";

    }

    public interface TaskSyncColumns {

	public static final String _DELETED = "_deleted";

    }

    public interface TaskListColumns {

	public static final String _ID = "_id";

	public static final String NAME = "name";

	public static final String COLOR = "color";

	public static final String ACCESS_LEVEL = "access_level";

	public static final String VISIBLE = "visible";

	public static final String SYNC_ENABLED = "sync_enabled";

	public static final String OWNER = "owner";

    }

    public static final class TaskLists implements TaskListColumns, CommonSyncColumns {

	public static final String CONTENT_URI_PATH = "tasklists";

	public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/" + CONTENT_URI_PATH);

	public static final String DEFAULT_SORT_ORDER = _ID;

	public static final String[] SYNC_ADAPTER_COLUMNS = new String[] { ACCESS_LEVEL, _DIRTY, OWNER, SYNC1, SYNC2,
		SYNC3, SYNC4, SYNC5, SYNC6, SYNC7, SYNC8, SYNC_SOURCE, SYNC_VERSION, };

    }

    public interface TaskColumns {

	public static final String _ID = "_id";

	public static final String LIST_ID = "list_id";

	public static final String TITLE = "title";

	public static final String LOCATION = "location";

	public static final String DESCRIPTION = "description";

	public static final String COMMENT = "comment";

	public static final String PRIORITY = "priority";

	public static final int PRIORITY_DEFAULT = 0;

	public static final String CLASSIFICATION = "class";

	public static final int CLASSIFICATION_PUBLIC = 0;

	public static final int CLASSIFICATION_PRIVATE = 1;

	public static final int CLASSIFICATION_CONFIDENTIAL = 2;

	public static final int CLASSIFICATION_DEFAULT = CLASSIFICATION_PUBLIC;

	public static final String COMPLETED = "completed";

	public static final String PERCENT_COMPLETE = "percent_complete";

	public static final String STATUS = "status";

	public static final int STATUS_NEEDS_ACTION = 0;

	public static final int STATUS_COMPLETED = 1;

	public static final int STATUS_IN_PROCESS = 2;

	public static final int STATUS_CANCELLED = 3;

	public static final int STATUS_DEFAULT = STATUS_NEEDS_ACTION;

	public static final String COLOR = "color";

	public static final String DTSTART = "dtstart";

	public static final String TZ = "tz";

	public static final String DUE = "due";

	public static final String DURATION = "duration";

	public static final String EXDATES = "exdates";

	public static final String EXRULE = "exrule";

	public static final String ORIGINAL_INSTANCE = "ortiginal_instance";

	public static final String ORIGINAL_INSTANCE_TIME = "ortiginal_instance_time";
    }

    public static final class Tasks implements TaskColumns, CommonSyncColumns, TaskSyncColumns {

	public static final String CONTENT_URI_PATH = "tasks";

	public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/" + CONTENT_URI_PATH);

	public static final String DEFAULT_SORT_ORDER = TITLE;

	public static final String[] SYNC_ADAPTER_COLUMNS = new String[] { _DIRTY, SYNC1, SYNC2, SYNC3, SYNC4, SYNC5,
		SYNC6, SYNC7, SYNC8, SYNC_SOURCE, SYNC_VERSION, };
    }

    /**
     * Available values in Categories.
     * 
     * Categories are per account. It's up to the front-end to ensure consistency of category colors across accounts.
     * 
     * @author Marten Gajda <marten@dmfs.org>
     */
    public interface CategoriesColumns {

	public static final String _ID = "_id";

	public static final String ACCOUNT_NAME = "account_name";

	public static final String ACCOUNT_TYPE = "account_type";

	public static final String NAME = "name";

	public static final String COLOR = "color";
    }

    public static final class Categories implements CategoriesColumns {

	public static final String CONTENT_URI_PATH = "categories";

	public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/" + CONTENT_URI_PATH);

	public static final String DEFAULT_SORT_ORDER = NAME;

    }

}
